package com.bean;

import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionEvent;
import java.io.Serializable;
import java.util.Date;

public class Student implements HttpSessionActivationListener, Serializable {
    private Integer id;
    private String name;
    private Integer age;

    public Student(Integer id, String name, Integer age) {
        this.id = id;
        this.name = name;
        this.age = age;
    }

    public Student() {
    }

    @Override
    public void sessionWillPassivate(HttpSessionEvent se) {
        System.out.println("SessionId = " + se.getSession().getId());
        System.out.println("Session将要被钝化：" + new Date());
    }

    @Override
    public void sessionDidActivate(HttpSessionEvent se) {
        System.out.println("SessionId = " + se.getSession().getId());
        System.out.println("Session已经被活化：" + new Date());
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}
